import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
import axios from "axios";
export default new Vuex.Store({
  state: {
    swiper:[],
    classify:[],
    activeKey: 0,
  },
  mutations: {
    renderSwiper(state,arr){
     state.swiper = arr
    },
    renderClassify(state,arr){
      state.classify = arr
     },
     tab(state,index){
      state.activeKey = index
     }
  },
  actions: {
    renderSwiper(context){
      axios.get("/swiper").then((res) => {
        context.commit("renderSwiper",res.data)
      });
    },
    renderClassify(context){
      axios.get("/classify").then((res) => {
        context.commit("renderClassify",res.data)
      });
    }
  },
  modules: {
  }
})
